import request from '@/utils/request'

// 获取路由
export function getRoutes() {
  return request({
    url: '/permission/0',
    method: 'get'
  })
}

export function getRoutesByRole(roleId) {
  return request({
    url: `/permission/role/${roleId}`,
    method: 'get'
  })
}

export function getRoles() {
  return request({
    url: '/role',
    method: 'get'
  })
}

// 查询用户的角色
export function getUserRole() {
  return request({
    url: '/role/user',
    method: 'get'
  })
}

export function addRole(data) {
  return request({
    url: '/role',
    method: 'post',
    data
  })
}
// 给用户分配角色
export function addUserRole(userId, data) {
  return request({
    url: `/role/user/${userId}`,
    method: 'post',
    data
  })
}

export function modifyRole(id, data) {
  return request({
    url: `/role/${id}`,
    method: 'put',
    data
  })
}

export function deleteRole(id, status) {
  return request({
    url: `/role/status/${id}?status=${status}`,
    method: 'put'
  })
}
